/*******************************************************************************
Date: 31.01.2024

Title: "The Labor Market Effects of Loan Guarantee Programs" 

Authors: Jean-Noel Barrot, Thorsten Martin, Julien Sauvagnat, Boris Vallée

Description: This file produces the figures and tables of the paper 
*******************************************************************************/

/*******************************************************************************
Table 1: Summary statistics
*******************************************************************************/

cap erase table1_ss.tex

// Panel A Loan Guarantee Program
use firm_sample, replace

cap drop n_reg
bysort reg: gen n_reg = _n

eststo clear
quietly estpost summarize apr_renfo_r0810 res_10 if n_reg == 1, detail
esttab using table1.tex, cells("count mean(fmt(3)) sd(fmt(3))  p1(fmt(3)) p50(fmt(3)) p99(fmt(3))") title("Summary Statistics") label append

quietly estpost summarize apr_renfo_r0810_f apr_renfo_r0810_fd lossat default, detail
esttab using table1.tex, cells("count mean(fmt(3)) sd(fmt(3))  p1(fmt(3)) p50(fmt(3)) p99(fmt(3))") title("Summary Statistics") label append

// Panel B - C Worker-level
use worker_sample, replace
eststo clear
quietly estpost summarize emp_years sum_wage0915_norm separation sum_ui0915_norm sn_2008 nbheur_2008 age sx, detail
esttab using table1.tex, cells("count mean(fmt(3)) sd(fmt(3))  p1(fmt(3)) p50(fmt(3)) p99(fmt(3))") title("Summary Statistics") label append

// Panel D Firm-level
use firm_sample, replace

quietly estpost summarize d2009_bdbt_fd bdbt_fd_2008 d0910_ir ir08 effsalm at prof firmage divs ppe_to_assets debt_to_assets creditrisk tfp2008 vaht_emp2008, detail
esttab using table1.tex, cells("count mean(fmt(3)) sd(fmt(3))  p1(fmt(3)) p50(fmt(3)) p99(fmt(3))") title("Summary Statistics") label append

/*******************************************************************************
Table 2: First stage: Firm-level exposure to the loan guarantee program
*******************************************************************************/

cap erase table2.tex

use firm_sample, replace

local TREAT 		res_10   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local FE			gdep ape3
local CL  			reg

// Panel A: Credit
eststo clear
eststo: reghdfe apr_renfo_r0810_f 	`CONTROLS' `FCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe apr_renfo_r0810_fd 	`CONTROLS' `FCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe d2009_bdbt_fd 		`CONTROLS' `FCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe d0910_ir  			`CONTROLS' `FCONTROLS', a(`FE') cl(`CL') 
esttab using table2.tex, append  title("Firm-level") noconstant addnote("dep-pair FE - cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

// Panel B: Labor & productivity
eststo clear
eststo: reghdfe demp0810 			`CONTROLS' `FCONTROLS' [aw=effsalm], a(`FE') cl(`CL') 
eststo: reghdfe dva_emp0810 		`CONTROLS' `FCONTROLS' [aw=effsalm], a(`FE') cl(`CL') 
eststo: reghdfe demp0815 			`CONTROLS' `FCONTROLS' [aw=effsalm], a(`FE') cl(`CL') 
eststo: reghdfe dtfp_0815  			`CONTROLS' `FCONTROLS' [aw=effsalm], a(`FE') cl(`CL') 
esttab using table2.tex, append  title("Firm-level") noconstant addnote("dep-pair FE - cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 


/*******************************************************************************
Table 3: Worker-level employment effects
*******************************************************************************/

cap erase table3.tex

use worker_sample, replace

local TREAT 		res_10
local RAWTREAT 		apr_renfo_r0810   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk 
local WCONTROLS		age_08 sx 
local PAIRFE		gdep 
local CL  			reg

// Panel A: Baseline
eststo clear
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS'    		 	, a(`PAIRFE' ape3) cl(`CL')
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	, a(`PAIRFE' ape3 occupation_id) cl(`CL')
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS'    			, a(`PAIRFE' ape3) cl(`CL')
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  , a(`PAIRFE' ape3 occupation_id) cl(`CL') 
esttab using table3.tex, append  title("Worker-level employment") se noconstant addnote("dep-pair FEs - cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

// Panel B: 2SLS
eststo: reghdfe emp_years 			`CONTROLS' `FCONTROLS' 				(apr_renfo_r0810_f=`TREAT') , a(`PAIRFE' ape3) cl(`CL') 
eststo: reghdfe emp_years 			`CONTROLS' `FCONTROLS' `WCONTROLS' 	(apr_renfo_r0810_f=`TREAT') , a(`PAIRFE' ape3 occupation_id) cl(`CL') 
eststo: reghdfe sum_wage0915_norm 	`CONTROLS' `FCONTROLS' 				(apr_renfo_r0810_f=`TREAT') , a(`PAIRFE' ape3) cl(`CL') 
eststo: reghdfe sum_wage0915_norm 	`CONTROLS' `FCONTROLS' `WCONTROLS'  (apr_renfo_r0810_f=`TREAT') , a(`PAIRFE' ape3 occupation_id) cl(`CL') 
esttab using table3.tex, append  title("Worker-level employment") se noconstant addnote("dep-pair FEs - cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2 widstat) b(3) 

// Panel C: Raw treatment
eststo clear
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS'    		 	, a(`PAIRFE' ape3) cl(`CL')
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	, a(`PAIRFE' ape3 occupation_id) cl(`CL')
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS'    			, a(`PAIRFE' ape3) cl(`CL')
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	, a(`PAIRFE' ape3 occupation_id) cl(`CL') 
esttab using table3.tex, append  title("Worker-level employment") se noconstant addnote("dep-pair FEs - cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

/*******************************************************************************
Table 4: Adjustment margins and worker reallocation
*******************************************************************************/

cap erase table4.tex

use worker_sample, replace

local TREAT 		res_10
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk 
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

eststo clear
eststo: reghdfe emp_years			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employeds_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedos_years	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
esttab using table4, append title("Adjustment margins") se noconstant addnote("cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

eststo clear
eststo: reghdfe sum_wage0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wages0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wageos0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL')
esttab using table4, append title("Adjustment margins") se noconstant addnote("cl(`CL')") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

/*******************************************************************************
Table 5: Employment effects and local labor market conditions
*******************************************************************************/

cap erase table5.tex

use worker_sample, replace

local TREAT 		res_10  
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans 
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg
local var  			high_unempc

eststo clear
eststo: reghdfe emp_years			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe employeds_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe emp_years			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe employeds_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe emp_years			`var'_`TREAT' `TREAT' `var'#c.(`CONTROLS' `FCONTROLS' `WCONTROLS') , a(`var'#gdep `var'#ape3  `var'#occupation_id) `CL'
eststo: reghdfe employeds_years		`var'_`TREAT' `TREAT' `var'#c.(`CONTROLS' `FCONTROLS' `WCONTROLS') , a(`var'#gdep `var'#ape3  `var'#occupation_id) `CL'
esttab using table5.tex, keep(`var'_`TREAT' `TREAT') append title("Local labor market conditions") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

eststo clear
eststo: reghdfe sum_wage0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe sum_wages0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe sum_wage0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe sum_wages0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe sum_wage0915_norm	`var'_`TREAT' `TREAT' `var'#c.(`CONTROLS' `FCONTROLS' `WCONTROLS') , a(`var'#gdep `var'#ape3  `var'#occupation_id) `CL'
eststo: reghdfe sum_wages0915_norm	`var'_`TREAT' `TREAT' `var'#c.(`CONTROLS' `FCONTROLS' `WCONTROLS') , a(`var'#gdep `var'#ape3  `var'#occupation_id) `CL'
esttab using table5.tex,  keep(`var'_`TREAT' `TREAT') append title("Local labor market conditions") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

/*******************************************************************************
Table 6: Heterogenous effects - Labor hoarding
*******************************************************************************/

cap erase table6.tex

use firm_sample, replace

local TREAT 		res_10
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FE			gdep ape3
local CL  			reg

foreach var in high_wage high_difficulty high_skill {

eststo clear
eststo: reghdfe demp0810 `TREAT' `CONTROLS' `FCONTROLS' [aw=effsalm] if `var' == 1, a(`FE') cl(`CL')  
eststo: reghdfe demp0810 `TREAT' `CONTROLS' `FCONTROLS' [aw=effsalm] if `var' == 0, a(`FE') cl(`CL')  
}
esttab using table6.tex, append  title("Labor hoarding") se noconstant star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

use worker_sample, replace

local TREAT 		res_10  
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans 
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

foreach var in high_wage high_diff_fd high_nr_cog_anal {

eststo clear
eststo: reghdfe employeds_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe employeds_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 0, a(`FE') cl(`CL') 
}
esttab using table6.tex, keep(`TREAT') append title("Labor hoarding") se noconstant star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

foreach var in high_wage high_diff_fd high_nr_cog_anal {

eststo clear
eststo: reghdfe sum_wages0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe sum_wages0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 0, a(`FE') cl(`CL') 
esttab using table6.tex, keep(`TREAT') append title("Labor hoarding") se noconstant star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 
}

/*******************************************************************************
Table 7: Dampened worker reallocation to more productive firms
*******************************************************************************/

cap erase table7.tex

use worker_sample, replace

local TREAT 		res_10
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk 
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

eststo clear
eststo: reghdfe employedos_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedhvae_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedlvae_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedhtfp_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedltfp_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedhroa_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedlroa_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedhsg_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe employedlsg_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
esttab using table7, append title("Worker reallocation to productive firms") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

eststo clear
eststo: reghdfe sum_wageos0915_norm		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL')
eststo: reghdfe sum_wagehvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wagelvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehtfp0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wageltfp0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wagelvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehtfp0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
eststo: reghdfe sum_wageltfp0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS', a(`FE') cl(`CL') 
esttab using table7, append title("Worker reallocation to productive firms") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

/*******************************************************************************
Table 8: Heterogeneity in reallocation dampening by worker characteristics
*******************************************************************************/

cap erase table8.tex

use worker_sample, replace

local TREAT 		res_10
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk 
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

foreach var in high_wage high_diff_fd high_nr_cog_anal {

eststo clear
eststo: reghdfe employedhvae_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe employedlvae_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe employedhvae_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe employedlvae_years		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if `var' == 0, a(`FE') cl(`CL') 
esttab using table8.tex, keep(`TREAT') append title("Worker reallocation - Heterogeneity") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

eststo clear
eststo: reghdfe sum_wagehvae0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe sum_wagelvae0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 1, a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehvae0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 0, a(`FE') cl(`CL') 
eststo: reghdfe sum_wagelvae0915_norm	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS'  if `var' == 0, a(`FE') cl(`CL') 
esttab using table8.tex, keep(`TREAT') append title("Worker reallocation - Heterogeneity") se noconstant addnote("`FE' `FCONTROLS' `WCONTROLS'") star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 
}

/*******************************************************************************
Table 9: Placebo test using firms with low take-up propensity
*******************************************************************************/

cap erase table9.tex

use worker_sample, replace

local TREAT 		res_10   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FFE			gdep ape3
local FE			gdep ape3 occupation_id
local CL  			reg

// Baseline
estimates clear
eststo: reghdfe apr_renfo_r0810_f 	`TREAT' `CONTROLS' `FCONTROLS'  			if low_prop==0	,a(`FFE') cl(`CL') 
eststo: reghdfe apr_renfo_r0810_f 	`TREAT' `CONTROLS' `FCONTROLS'				if low_prop==1 	,a(`FFE') cl(`CL') 
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if low_prop==0 	,a(`FE')  cl(`CL') 
eststo: reghdfe emp_years 			`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if low_prop==1 	,a(`FE')  cl(`CL') 
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if low_prop==0 	,a(`FE')  cl(`CL') 
eststo: reghdfe sum_wage0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' 	if low_prop==1 	,a(`FE')  cl(`CL') 
esttab using table9.tex, append title("Placebo: Split Treatment Propensity") se noconstant star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 

// Reallocation
estimates clear
eststo: reghdfe employedhvae_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if low_prop==0	,a(`FE') cl(`CL') 
eststo: reghdfe employedhvae_years 		`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if low_prop==1 	,a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if low_prop==0	,a(`FE') cl(`CL') 
eststo: reghdfe sum_wagehvae0915_norm 	`TREAT' `CONTROLS' `FCONTROLS' `WCONTROLS' if low_prop==1 	,a(`FE') cl(`CL') 
esttab using table9.tex, append title("Placebo: Split Treatment Propensity") se noconstant star(* 0.1 ** 0.05 *** 0.01) label scalars(r2) b(3) 


/*******************************************************************************
Figure 1: Labor productivity by guarantee status
*******************************************************************************/

// Load firm data 2008
use firm_data_2008, replace

merge 1:1 siren using guarantee_firms // merge with list of firms obtaining guarantee under recovery plan
gen d_guarantee 	= (_m==3)
gen d_no_guarantee 	= (_m==1)
drop if _m == 2
drop _m

label var effsalm 			"Nb Employees"
label var vaht_effsalm08 	"VA/Emp (000s)"
label var d_no_guarantee 	" "

statsby mean=r(mean) ub=r(ub) lb=r(lb) N=r(N), by(d_no_guarantee) clear: ci mean vaht_effsalm08 [aw=effsalm], level(99.99)
twoway bar mean d_treated, barw(0.85) ytitle("") xlabel(0 "Guarantee" 1 "No Guarantee") xscale(range(-1(1)2)) yscale(range(45(5)65)) ylabel(45(5)65) || rcap ub lb d_treated, legend(off)
gr export figure1.pdf, replace


/*******************************************************************************
Figure 2: Yearly volume of guarantees by Bpifrance recovery plan
*******************************************************************************/
use guarantee_volume, replace

twoway (bar guarantee_volume year), ytitle("Guaranteed loans (million euros)") legend(off)
gr export figure2.pdf, replace

/*******************************************************************************
Figure 3: Regional intensity of loan guarantee intervention
*******************************************************************************/
use francemapdep, clear
gen nuts2=substr(nuts3,1,4)
*Value residualized treatment by region added manually
gen treatment=-.03 if nuts2=="FR10"
replace treatment=.00 if nuts2=="FR21"
replace treatment=-.05 if nuts2=="FR22"
replace treatment=-.02 if nuts2=="FR23"
replace treatment=-.05 if nuts2=="FR24"
replace treatment=-.01 if nuts2=="FR25"
replace treatment=.05 if nuts2=="FR26"
replace treatment=-.02 if nuts2=="FR30"
replace treatment=.30 if nuts2=="FR41"
replace treatment=-.02 if nuts2=="FR42"
replace treatment=.18 if nuts2=="FR43"
replace treatment=-.00 if nuts2=="FR51"
replace treatment=.02 if nuts2=="FR52"
replace treatment=-.07 if nuts2=="FR53"
replace treatment=-.01 if nuts2=="FR61"
replace treatment=-.08 if nuts2=="FR62"
replace treatment=.72 if nuts2=="FR63"
replace treatment=.06 if nuts2=="FR71"
replace treatment=.10 if nuts2=="FR72"
replace treatment=-.13 if nuts2=="FR81"
replace treatment=-.06 if nuts2=="FR82"

drop if missing(treatment)
spmap treatment using "frcoordep.dta", legenda(on) fcolor(Reds) id(id) clnumber(9) ocolor(black) mosize(msize(*.01) ..) osize(vvthin ..) polygon(data("frcoord.dta") ocolor(none ..) fcolor(gs9) osize(vvthin) leglabel(Municipalities within 10 miles) legenda(on)) line(data("frcoordreg.dta") size(vthin) color(black) legenda(on) leglabel(Regional borders)) 
graph export  "colordis_res.png", replace

/*******************************************************************************
Figure 4: Regional treatment intensity, firm take-up propensity and take-up
*******************************************************************************/
use firm_sample, replace

xtile prop5 = propensity, nq(5)
tab prop5, gen(PROP)

forvalues i=1/5{
gen res_10_PROP`i'=res_10*PROP`i'
label var int_PROP`i' "`i'"
}

local TREAT 		res_10   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local FE			gdep ape3
local CL  			reg

eststo clear
eststo: reghdfe apr_renfo_r0810_fd `TREAT'_PROP* PROP* `TREAT', a(`FE') cl(`CL')
coefplot , vertical keep(`TREAT'_PROP*) recast(connected) ciopts(recast(rcap)) ytitle("Guarantee (1/0)") xtitle("Guarantee Propensity")
gr export figure4.pdf, replace

/*******************************************************************************
Figure 5: Dynamics: Effect on earnings
*******************************************************************************/

local TREAT 		res_10   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

foreach var in wage wages wageos  {

use worker_sample_draft, replace
estimates clear
foreach y in 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {
reghdfe `var'_`y'_norm_w `TREAT'  `CONTROLS' `FCONTROLS' `WCONTROLS' , a(`FE') cl(`CL') 
quietly parmest, label list(parm label estimate min* max* p) saving(results_`var'_`y', replace)
}


foreach year in 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {
use results_`var'_`year', replace
keep if _n == 1
keep parm estimate min95 max95
rename parm year
replace year = "`year'"
destring year, replace
save results_`var'_`year', replace
}

use results_`var'_2004, replace
foreach year in  2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {

append using results_`var'_`year'
}
save graph_results_`var'_controls_`TREAT', replace

twoway (scatter estimate year, ylabel(-0.1(0.05)0.1 ,angle(horizontal)) yline(0) yscale(range(-0.1(0.05)0.1)) xline(2008.5, lwidth(2.5) lcolor(gs13)) connect(direct) xlabel(#12) legend(off)) (rcap min95 max95 year, lcolor(navy)), xtitle("") 
gr export figure5_`var'.pdf, replace
}

/*******************************************************************************
Figure 6: Effect on earnings at other firms: Split by productivity measures
*******************************************************************************/

local TREAT 		res_10   
local CONTROLS  	disfrontier dln_value1_22010 dln_value2_22010 dln_value4_22010 dln_value5_22010 dln_value6_22010 dln2_vaht_non_pme_pc_full dln_gross_loans
local FCONTROLS		lnfirmage lnat prof divs ppe_to_assets debt_to_assets creditrisk   
local WCONTROLS		age_08 sx 
local FE			gdep ape3 occupation_id
local CL  			reg

foreach var in wagehvae wagelvae wagehtfp wageltfp {

use worker_sample_draft, replace
estimates clear
foreach y in 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {
reghdfe `var'_`y'_norm_w `TREAT'  `CONTROLS' `FCONTROLS' `WCONTROLS' , a(`FE') cl(`CL') 
quietly parmest, label list(parm label estimate min* max* p) saving(results_`var'_`y', replace)
}


foreach year in 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {
use results_`var'_`year', replace
keep if _n == 1
keep parm estimate min95 max95
rename parm year
replace year = "`year'"
destring year, replace
save results_`var'_`year', replace
}

use results_`var'_2004, replace
foreach year in  2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 {

append using results_`var'_`year'
}
save graph_results_`var'_controls_`TREAT', replace

twoway (scatter estimate year, ylabel(-0.1(0.05)0.1 ,angle(horizontal)) yline(0) yscale(range(-0.1(0.05)0.1)) xline(2008.5, lwidth(2.5) lcolor(gs13)) connect(direct) xlabel(#12) legend(off)) (rcap min95 max95 year, lcolor(navy)), xtitle("") 
gr export figure6_`var'.pdf, replace
}
